home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cc04.arc / STRLEN.C < prev    next >
Encoding:
C/C++ Source or Header  |  1986-03-15  |  467 b   |  41 lines

  1. /* -- strlen.c    string length measuring program -- */
  2.  
  3. #include "stdio.h"
  4.  
  5. #define NTIMES 25000
  6. #define S "Now is the time for all good men to come to the aid of the parity."
  7.  
  8. main {                    /* repeatedly measure length of string */
  9.  
  10.     int i;
  11.  
  12.     for (i = 1; i <= NTIMES; i++)
  13.         string(s);
  14.     exit(0);
  15. }
  16.  
  17. string(s)                /*return length of string */
  18.  
  19. char *s;
  20.  
  21. {
  22.     char *p;
  23.  
  24.     for (p = s; *s != '\0'; s++)
  25.         ;
  26.  
  27.     return(s - p);
  28. }
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.